import Vue from "vue";
import Router from "vue-router";
// import HelloWorld from '@/components/HelloWorld'
import store from "../store";
import Login from "../view/Login.vue";
import userinfo from "../view/userinfo.vue";

Vue.use(Router);

const router = new Router({
    routes: [{
            path: "/",
            redirect: "/userinfo",
        },

        {
            path: "/login",
            name: "Login",
            component: Login,
        },

        {
            path: "/userinfo",
            name: "userinfo",
            component: userinfo,
        },
    ],
});

const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err);
};
// 在于Vue-router在3.1之后把$router.push()方法改为了Promise。所以假如没有回调函数，错误信息就会交给全局的路由错误处理，因此就会报上述的错误。
// 禁止全局路由错误处理打印，这个也是vue-router开发者给出的解决方案：
export default router;